<template>
  <div class="content">
    <div class="cont_all">
      <div class="cont_call">
        <i class="el-icon-phone-outline" style="margin-right: 5px"></i>
        <span>联系电话：{{ calls }}</span>
      </div>

      <div class="cont_lot">
        <span style="margin-right: 10px" @click="userDisplays">{{
          login
        }}</span>
        <span style="width: 100px" @click="publish_01()"> {{ publish }} </span>
      </div>
    </div>

    <div class="users" v-show="userDisplay">
      <div class="usersz">
        <el-avatar icon="el-icon-user-solid"></el-avatar>
        <p @click="myPaper"><i class="el-icon-document"></i>我的论文</p>
        <p @click="downLogin" style="margin-top: 5px">
          <i class="el-icon-key"></i>退出登录
        </p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      calls: 18853985679,
      publish: "发表论文",
      login: "登录",
      userDisp: false,
      userDisplay: false,
    };
  },
  mounted() {
    const z = localStorage.getItem("token_z");
    if (z) {
      this.login = "用户";
      // this.userDisp = true;
    } else {
      this.login = "登录";
      // this.userDisp = false;
    }
  },
  methods: {
    myPaper() {
      this.$router.push({
          name: "tables",
        });
    },
    downLogin() {
      if (this.userDisplay == true) {
        this.userDisplay = false;
      }
      this.$notify({
        duration: 1500,
        title: "成功",
        message: "账号退出成功！",
        type: "success",
      });
      localStorage.removeItem("token_z");
      this.login = "登录";
    },
    userDisplays() {
      if (this.login == "用户") {
        if (this.userDisplay == false) {
          this.userDisplay = true;
        } else {
          this.userDisplay = false;
        }
      } else if (this.login == "登录") {
        this.$router.push({
          path: "/login",
        });
      }
    },
    // 发表论文
    publish_01() {
      if (localStorage.getItem("token_z")) {
        this.$notify({
          duration: 1500,
          title: "成功",
          message: "跳转成功，祝您编写愉快！",
          type: "success",
        });
        this.$router.push({ path: "/newpaper" });
      } else {
        this.$notify.error({
          duration: 1500,
          title: "错误",
          message: "您还未登录账号，请登录后发布！",
        });
        this.$router.push({ path: "/login" });
      }
      // console.log("aa");
    },
  },
};
</script>

<style lang="less" scoped>
.el-avatar {
  margin-left: 50px;
}
a {
  text-decoration: none;
  color: white;
}
.content {
  width: 100%;
  height: 30px;
  // background: #303030;
  background: #ffffff;
  position: relative;
}
.cont_all {
  width: 1200px;
  margin: auto;
  // border: 1px solid red;
  height: 30px;
  position: relative;
  color: #a6a6a6;
  font-weight: bold;
  line-height: 30px;
}
.cont_call {
  position: absolute;
  left: 0px;
}
.cont_lot {
  position: absolute;
  right: 0px;
}
.cont_lot span {
  font-family: "宋体";
  display: block;
  float: left;
}
.cont_lot span:hover {
  cursor: pointer;
  font-size: 17px;
}
.cont_call span {
  font-family: "宋体";
}
.users {
  width: 140px;
  height: 110px;
  margin: 20px;
  background: #ffffff;
  overflow: hidden;
  border-radius: 5px;
  position: absolute;
  top: 12px;
  right: 205px;
  animation: showUser 1s;
  -webkit-animation: showUser 1s;
  z-index: 999;
}

.users p {
  cursor: pointer;
  text-align: center;
  width: 90px;
  margin: 0 auto;
  color: #a6a6a6;
}
.users p:hover {
  color: #c0c4cc;
}
.users p i {
  margin-right: 2px;
}
.usersz {
  margin-top: 10px;
}
.downLogin {
  margin-top: 10px;
}
// css动画
@keyframes showUser {
  //  0% {top:0px;right:200px;}
  // 100% { top:12px;right:200px;}
  0% {
    width: 140px;
    height: 0px;
  }
  100% {
    width: 140px;
    height: 110px;
  }
}
@-webkit-keyframes showUser {
  // 0%   {width: 140px;height: 0px;}
  // 100% { width: 140px;height: 110px;}
}
</style>

